/*
 * Filesystem.h
 *
 *  Created on: Mar 22, 2010
 *      Author: Lukasz Spintzyk
 */

#ifndef FILESYSTEM_H_
#define FILESYSTEM_H_

#ifdef PH_H_
#include "ph.h"
#endif

#ifndef SUPERBLOCK_H_
#include "SuperBlock.h"
#endif

#ifndef INODE_H_
#include "Inode.h"
#endif

#ifndef BLOCKREADER_H_
#include "BlockReader.h"
#endif

#ifndef INODEREADER_H_
#include "InodeReader.h"
#endif

#ifndef FILECONTAINER_H_
#include "FileContainer.h"
#endif

#ifdef UTILS_H_
#include "utils.h"
#endif

#ifndef COMMANDLINEPARSERS_H_
#include "CommandLineParsers.h"
#endif


class DirectoryReader;
class AesSwitchEncrypter;

class Filesystem
{
public:
    static boost::shared_ptr<Filesystem> setUp(const FilesystemMkfsArgs& opts, bool set_up_root = false);
    static boost::shared_ptr<Filesystem> read(const FilesystemMountArgs& opts);

    //void setSuperBlock(const SuperBlock& sb);
    SuperBlock& getSuperBlock();

    BlockManager* getBlockReader();
    InodeManager* getInodeReader();

    ~Filesystem();

    DirectoryReader* getDirectoryReader();

    FileContainer* getFileContainer();
protected:

    Filesystem(const FilesystemMountArgs& options);
    Filesystem(const SuperBlock& initialSb, const FilesystemMountArgs& options);
    void initFilesystem(const FilesystemMountArgs& options);

    std::string d_name;
    SuperBlock d_sb;
    bool d_chached;
    uint32_t cacheSize;
    AesSwitchEncrypter* d_encrypter;
    IOStream* d_io;
    BlockManager* d_reader;
    InodeManager* d_inodeMgr;
    DirectoryReader* d_dirReader;
    FileContainer* d_fileContainer;

};



#endif /* FILESYSTEM_H_ */
